package org.springframework.samples.petclinic.web

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.samples.petclinic.Clinic
import org.springframework.stereotype.Controller
import org.springframework.ui.ModelMap
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam

@Controller
class ClinicController {

  var clinic:Clinic = null
  
  @Autowired
  def setClinic(clinic:Clinic) = this.clinic = clinic
  
  @RequestMapping(Array("/welcome.do"))
  def welcomeHandler = {}
  
  @RequestMapping(Array("/vets.do"))
  def vetsHandler:ModelMap = new ModelMap(this.clinic.getVets)
  
  @RequestMapping(Array("/owner.do"))
  def ownerHandler(@RequestParam("ownerId") ownerId:Int):ModelMap = new ModelMap(this.clinic.loadOwner(ownerId))
}
